//
//  MVTableViewCell.m
//  23-QQ音乐
//
//  Created by 曹曹 on 16/8/15.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "MVTableViewCell.h"
#import "MVCollectionViewCell.h"
#import "MVConllectionList.h"
#import "MVTableList.h"

#define kCollectionViewCellReuse @"collectionViewCellReuse"

@interface MVTableViewCell () <UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UICollectionViewFlowLayout *layout;

@end

@implementation MVTableViewCell

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return _listArray.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    MVCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kCollectionViewCellReuse forIndexPath:indexPath];
    cell.list = _listArray[indexPath.row];
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return CGSizeMake(CGRectGetWidth(collectionView.bounds), CGRectGetHeight(collectionView.bounds) / 2 - 20);
    } else {
        return CGSizeMake((CGRectGetWidth(collectionView.bounds) - 10)/ 2, CGRectGetHeight(collectionView.bounds) / 4);
    }
}

- (void)setListArray:(NSArray<MVConllectionList *> *)listArray {
    _listArray = listArray;
    [_collectionView reloadData];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
